import math

def csum(num1, num2):
    return num1 + num2

def csud(num1, num2):
    return num1 - num2

def cmul(num1, num2):
    return num1 * num2

def cdev(num1, num2):
    if num2 == 0:
        print("除数不能为0")
        return 0
    return num1 / num2

def csin(num1):
    return math.sin(math.radians(num1))

def ccos(num1):
    return math.cos(math.radians(num1))

def ctan(num1):
    return math.tan(math.radians(num1))

def clog(num1, num2):
    if num1 <= 0:
        print("对数的真数必须大于0")
        return 0
    if num2 <= 0 or num2 == 1:
        print("对数的底数必须大于0且不等于1")
        return 0
    return math.log(num1, num2)

def cexp(num1, num2):
    if num2 < 0:
        print("指数的底数不能为负数")
        return 0
    return num1 ** num2

while True:
    print("请选择运算类型：1. 加法 2. 减法 3. 乘法 4. 除法 5. 正弦 6. 余弦 7. 正切 8. 对数 9. 指数")
    choice = input("请输入选择的运算类型序号：")

    if choice in ["1", "2", "3", "4"]:
        num1 = float(input("请输入第一个数："))
        num2 = float(input("请输入第二个数："))
        if choice == "1":
            print("num1 + num2 =", csum(num1, num2))
        elif choice == "2":
            print("num1 - num2 =", csud(num1, num2))
        elif choice == "3":
            print("num1 * num2 =", cmul(num1, num2))
        elif choice == "4":
            print("num1 / num2 =", cdev(num1, num2))
    elif choice in ["5", "6", "7"]:
        num1 = float(input("请输入角度值："))
        if choice == "5":
            print("sin(num1) =", csin(num1))
        elif choice == "6":
            print("cos(num1) =", ccos(num1))
        elif choice == "7":
            print("tan(num1) =", ctan(num1))
    elif choice == "8":
        num1 = float(input("请输入对数的真数："))
        num2 = float(input("请输入对数的底数："))
        result = clog(num1, num2)
        if result != 0:
            print("log(num2)(num1) =", result)
    elif choice == "9":
        num1 = float(input("请输入指数的底数："))
        num2 = float(input("请输入指数的指数值："))
        result = cexp(num1, num2)
        if result != 0:
            print("num1^num2 =", result)
    else:
        print("无效的输入，请重新输入！")

    conti = input("是否继续？y/n：")
    if conti.lower() != "y":
        break